package com.neuedu.outpatient01.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neuedu.outpatient01.entity.Medicaldisease;
import com.neuedu.outpatient01.entity.Medicalrecord;
import com.neuedu.outpatient01.entity.Register;
import com.neuedu.outpatient01.service.MedicaldiseaseService;
import com.neuedu.outpatient01.service.MedicalrecordService;
import com.neuedu.outpatient01.service.RegisterService;


@RestController
@RequestMapping("/outpatientDiagnosis")
public class OutpatientDiagnosis {
	@Autowired
	private RegisterService rservice;
	@Autowired 
	private MedicalrecordService mservice;
	@Autowired
	private MedicaldiseaseService mdservice;
	//查询未确诊患者信息 研究一下连表查询
	@RequestMapping("/selectNoDiagnosisRegister")
	//http://localhost:8090/outpatientDiagnosis/selectNoDiagnosisRegister
	public List<Register> selectNoDiagnosisRegister(Register r){
		return rservice.selectNoDiagnosisRegister(r);
	}
	
	//显示患者的信息
	@RequestMapping("/inquireHomeInfromation")
	//http://localhost:8090/outpatientDiagnosis/inquireHomeInfromation
	public Medicalrecord inquireHomeInfromation(Medicalrecord m) {
		return mservice.inquireHomeInfromation(m);
	}
	//更新患者首页表
	public int updateHomeInfromation(Medicalrecord m) {
		return mservice.updateHomeInfromation(m);
	}
	//更新患者诊断表
	public int updateDiseaseInfor(Medicaldisease md) {
		return mdservice.updateDiseaseInfor(md);
	}
	//查询患者诊断表
	public Medicaldisease inquireHistoryMDiseas(Integer MedicalID) {
		return mdservice.inquireHistoryMDiseas(MedicalID);
	}
	//提交患者信息，改为终诊
	@RequestMapping("/Diagnosisimg")
	//http://localhost:8090/outpatientDiagnosis/Diagnosisimg
	public String Diagnosisimg(Medicalrecord m) {
		System.out.println("--m"+m);
		if(inquireHistoryMDiseas(m.getID())!=null) {
			updateHomeInfromation(m);
			Medicaldisease md = new Medicaldisease();
			md = inquireHistoryMDiseas(m.getID());
			md.setDiagnoseCate(2);
			updateDiseaseInfor(md);
			return "成功";
		}else {
			return "失败";
		}
	}
	
}
